package com.qztc.news_end_core.enums;

import java.io.Serializable;

public class RespBean<T> implements Serializable {
    private int status;
    private String msg;
    private T data;

    private RespBean(int status){
        this.status=status;
    }

    public RespBean(int status, String msg){
        this.status=status;
        this.msg=msg;
    }

    public RespBean(int status, T data){
        this.status=status;
        this.data=data;
    }

    private RespBean(int status, String msg, T data){
        this.status=status;
        this.msg=msg;
        this.data=data;
    }

    public int getStatus(){
        return status;
    }

    public String getMsg(){
        return msg;
    }

    public T getData(){
        return data;
    }

    public static <T> RespBean<T> ok(){
        return new RespBean<T>(RespCode.SUCCESS.getCode());
    }

    public static <T> RespBean<T> ok(String msg){
        return new RespBean<T>(RespCode.SUCCESS.getCode(),msg);
    }

    public static <T> RespBean<T> ok(T data){
        return new RespBean<T>(RespCode.SUCCESS.getCode(),data);
    }


    public static <T> RespBean<T> ok(String msg,T data){
        return new RespBean<T>(RespCode.SUCCESS.getCode(),msg,data);
    }

    public static <T> RespBean<T> error(){
        return new RespBean<T>(RespCode.ERROR.getCode(),RespCode.ERROR.getDesc());
    }

    public static <T> RespBean<T> error(String errorMessage){
        return new RespBean<T>(RespCode.ERROR.getCode(),errorMessage);
    }

    public static <T> RespBean<T> error(int errorCode,String errorMessage){
        return new RespBean<T>(errorCode,errorMessage);
    }
}